package com.admin.service.impl;

import com.admin.entity.Announcement;
import com.admin.dao.AnnouncementMapper;
import com.admin.entity.Room;
import com.admin.service.AnnouncementService;
import com.admin.vo.query.AnnouncementQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 公告通知表 服务实现类
 * </p>
 *
 * @author szy
 * @since 2023-03-14
 */
@Service
public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Announcement> implements AnnouncementService {

    @Override
    public IPage<Announcement> getAnnountByPage(IPage<Announcement> page, AnnouncementQueryVo announcementQueryVo) {
        QueryWrapper<Announcement> queryWrapper = new QueryWrapper<Announcement>();
        //id
        queryWrapper.eq(!ObjectUtils.isEmpty(announcementQueryVo.getId()),
                "id",announcementQueryVo.getId());
        //标题
        queryWrapper.like(!ObjectUtils.isEmpty(announcementQueryVo.getTitle()),
                "title",announcementQueryVo.getTitle());
        //类型
        queryWrapper.like(!ObjectUtils.isEmpty(announcementQueryVo.getType()),
                "type",announcementQueryVo.getType());
        return baseMapper.selectPage(page,queryWrapper);
    }
}
